<template>
  <div class="list_mian">
    <div class="video_content">
      <div class="video_box"></div>
    </div>
    <el-row id="el-row" :gutter="20">
      <el-col v-for="(item, index) in playerConfig" :key="item.id" :span="span">
        <div class="card_comment">
          <el-card 
          class="card" 

          :body-style="{ padding: '0px' }">
          <Video  ref="video"    @click="handleClick(item.id)" class="video" :id="item.id" :defaultConfig='defaultConfig' :config="item" :rootStyle="rootStyle" @playerInit="onPlayerInit"></Video>
         
            <div class="context" style="padding: 14px">
              <div class="title">{{ item.name }}</div>
              <div class="bottom">
                <time class="name"></time>
              </div>
            </div>
          </el-card>
          <div ref="comment" class="comment_big">
            <Comment></Comment>
          </div>
          <!-- <div ref="comment" class="comment">
            <Comment></Comment>
          </div> -->

        </div>
      </el-col>
    </el-row>

    <VideoInfo :idnum="idnum" v-show="videoShow"  @handleClose="handleClose"></VideoInfo>
  </div>
</template>

<script setup>
import { ref,reactive, onMounted, onUnmounted,defineProps } from 'vue'
import {request} from "@/utils/request"
import Video from '@/components/video'
import VideoInfo from '@/components/VideoInfo.vue'
import Comment from '@/components/comment'

//基础配置
const defaultConfig = reactive({
  // el: "mse",
  // id:'',
  fluid: true, //自适应视频内容宽高
  fitVideoSize: "auto", //自适应视频内容宽高
  autoplay: false,
  videoInit: true, //初始化显示视频首帧
//   playbackRate: [0.5, 0.75, 1, 1.5, 2],
//   defaultPlaybackRate: 1,
  playsinline: true,
  lang: "zh-cn",
  volume: 0.6,
  fitVideoSize:'fixWidth',
  height:90
  // closeFocusVideoFocus:true,
 
  // inactive:0,
  
});

//video部分
let player=ref(null)
const rootStyle={
  backgroundColor: "rgba(0,0,0,0.87)"
}
//接收video组件初始化好的视频对象
let onPlayerInit=(val)=>{
  console.log('1111111111111111')
  player.value= val;
}
const {url,params}=defineProps({
  url: {
      type: String,
      default() {
        return {};
      }
    },
  params:{
    type: Object,
      default() {
        return {};
      }
  }
})

//接入视频
let playerConfig=ref([])
async function getList(){
  const resp =await request(url,{
    method:'GET',
    params:params})
    console.log('list:',resp.payload)
    // playerConfig.value = [resp.payload[0]]
    playerConfig.value = resp.payload
}
// playerConfig.value=[{
//   id: 1,
// name: "ROG掌机性能分析：最强掌机来啦！",
// poster: "http://s3hdmp00b.hn-bkt.clouddn.com/geek/ROG掌机性能分析：最强掌机来啦！_shot.jpg",
// url:"http://s3hdmp00b.hn-bkt.clouddn.com/geek/ROG掌机性能分析：最强掌机来啦！.mp4",
// }]
getList()

//监听窗口大小
var row_width = ref(document.documentElement.clientWidth)
const rowListener = () => {
  row_width.value = document.documentElement.clientWidth
  console.log('row_width',row_width.value)
  spanChange()
}

//改变span
let span = ref(4)
const spanChange = () => {
  if (row_width.value < 900) {
    span.value = 12
  } else if (row_width.value < 1200) {
    span.value = 8
  } else if (row_width.value < 1600) {
    span.value = 6
  } else {
    span.value = 4
  }
}
spanChange()

const idnum=ref(null)
const comment=ref(null)
const videoShow=ref(false)
let handleClick=(id)=>{
  videoShow.value=true
  idnum.value=id
  console.log('idnum',idnum.value)
}

//关闭视频播放
let handleClose=()=>{
  videoShow.value=false
}

onMounted(() => {
  window.addEventListener('resize', rowListener)
  defaultConfig.fullscreenTarget = document.querySelector('.video_box')
})
onUnmounted(() => {
  window.removeEventListener('resize', rowListener)
})
</script>

<style lang="less">
.list_mian::-webkit-scrollbar {
  width: 0em; /* 设置滚动条宽度 */
}

.list_mian::-webkit-scrollbar-thumb {
  background-color: transparent; /* 设置滚动条滑块颜色 */
}

.list_mian::-webkit-scrollbar-track {
  background-color: #f1f1f1; /* 设置滚动条轨道颜色 */
}
.el-col_big{
  box-sizing: border-box;
  height:100vh;
}
.comment_big{
  display:none;
}
.list_mian {
  position: relative;
  height:100%;
  width:100%;
  padding-top:60px;
  box-sizing: border-box;
  overflow-y: auto;
  .video_content{
    position: fixed;
    height:100vh;
    width: 100%;
    top:0px;
    left:0px;
    padding:60px;
    box-sizing: border-box;
    pointer-events: none;
    z-index:3;
    // background-color: aqua;
    .video_box{
      height:100vh;
      width:100%;
      // background-color: antiquewhite;
      margin:60px;
    }

  }
  .el-row {
    margin-top: 20px;
    width: 100%;
    .el-col {
      margin-bottom: 20px;
      width:100%;
      //放大时候
      // padding-top: 60px;
      // height:200px;
      // max-height:20vh;
      // max-height: 95vh;
      // min-width: 350px;
      // .card_comment{
      //   height:100%;
      //   width:100%;
      //   display:flex;
      //   flex-direction: row;
      //   .comment{
      //     flex:1;
      //     margin-left:10px;
      //     border-radius: 20px;;
      //   }
      // }
      .card {
        background-color: #252632;
        //方法
        // width: 75%;
        width: 100%;
        height:100%;
        border:0;
        border-radius: 20px;;
        // height:75%;
        .title {
          color: #FFFFFFE6;
          font-size: 1rem;
          line-height: 1.6rem;
          min-height: 3.2rem;
        }
        .name{
          
          font-size: 1rem;
          color: #FFFFFF80;
        }
      }
    }
  }
}

.bottom {
  margin-top: 13px;
  line-height: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.video {
  width: 100%;
  aspect-ratio: 4/2;
  display: block;
}
</style>
